/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package autowus.gui.module;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import polaczenie.polacz;
/**
 *
 * @author Quark
 */
public class DaysAppointmentsPanel extends javax.swing.JPanel {
      DaysAppointmentsModel m = new DaysAppointmentsModel();
   polacz p = new polacz();

boolean refresh=false;
  
    public JScrollPane getjScrollPane1() {
        return jScrollPane1;
    }

    public void setjScrollPane1(JScrollPane jScrollPane1) {
        this.jScrollPane1 = jScrollPane1;
    }
    /**
     * Creates new form DaysAppointments
     */
    public DaysAppointmentsPanel() {
  
 
 
       p.laczZBD();
      m.setWizyty(p.pobierzDzisiejszeWizyty());
        initComponents();
    }
public void odswiez() {
   /*
       this.m.wyczysc();
       this.p.laczZBD();
       this.m.setWizyty(this.p.pobierzDzisiejszeWizyty());
       daysAppointmentsTable.setModel(this.m);
       for(int c=0; c<daysAppointmentsTable.getColumnCount();c++){
                for  (int r=0; r<daysAppointmentsTable.getRowCount();r++){
                    System.out.println("r="+r+"c="+c);
        this.m.getValueAt(r, c);
                }
            }
            * 
         daysAppointmentsTable.revalidate();
         
           m.wyczysc();
            m.setModelData(p.pobierzDzisiejszeWizyty());
            for(int c=0; c<daysAppointmentsTable.getColumnCount();c++){
                for  (int r=0; r<daysAppointmentsTable.getRowCount();r++){
                    System.out.println("r="+r+"c="+c);
        m.getValueAt(r, c);
                }
            }
            * */
    //    initComponents();
        
      //    
       //   System.out.println(this.daysAppointmentsTable.getSize());
           //  m.setWizyty(p.pobierzDzisiejszeWizyty());
         /*   for(int c=0; c<daysAppointmentsTable.getColumnCount();c++){
                for  (int r=0; r<daysAppointmentsTable.getRowCount();r++){
                    System.out.println("r="+r+"c="+c);
        m.getValueAt(r, c);
                }
            }
            */
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jScrollPane1 = new javax.swing.JScrollPane();
        final javax.swing.JTable daysAppointmentsTable = new javax.swing.JTable();

        setBackground(new java.awt.Color(255, 255, 255));
        setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));
        setMaximumSize(new java.awt.Dimension(890, 355));
        setMinimumSize(new java.awt.Dimension(890, 355));
        setPreferredSize(new java.awt.Dimension(890, 355));

        jScrollPane1.repaint();

        //polacz p = new polacz();

        /*
        this.p.laczZBD();
        //m.wyczysc();
        this.m.setWizyty(this.p.pobierzDzisiejszeWizyty());
        * */
        daysAppointmentsTable.setModel(m
        );
        daysAppointmentsTable.setColumnSelectionAllowed(true);
        jScrollPane1.setViewportView(daysAppointmentsTable);
        daysAppointmentsTable.getColumnModel().getSelectionModel().setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION);
        daysAppointmentsTable.getColumnModel().getColumn(0).setResizable(false);
        daysAppointmentsTable.getColumnModel().getColumn(0).setPreferredWidth(1);
        daysAppointmentsTable.getColumnModel().getColumn(1).setResizable(false);
        daysAppointmentsTable.getColumnModel().getColumn(1).setPreferredWidth(1);
        this.refresh=true;
        daysAppointmentsTable.addMouseListener(new MouseAdapter() {
            public void mouseClicked(MouseEvent e) {

                daysAppointmentsTable.revalidate();

                m.wyczysc();
                m.setModelData(p.pobierzDzisiejszeWizyty());
                for(int c=0; c<daysAppointmentsTable.getColumnCount();c++){
                    for  (int r=0; r<daysAppointmentsTable.getRowCount();r++){
                        System.out.println("r="+r+"c="+c);
                        m.getValueAt(r, c);
                    }
                }

            }
        });

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 890, Short.MAX_VALUE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 355, Short.MAX_VALUE)
        );
    }// </editor-fold>//GEN-END:initComponents
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JScrollPane jScrollPane1;
    // End of variables declaration//GEN-END:variables
}
